package com.yindian.cos.easy.security.authentication.token;

/**
 * token存储的抽象
 *
 * @author zhangchuanhao
 * @create 2018/11/21
 */
public abstract class TokenStore {

    /**
     * 存储token
     *
     * @param token
     * @return
     */
    public abstract boolean saveToken(Token token);

    /**
     * 删除当前用户token
     *
     * @param accessToken
     */
    public abstract boolean removeToken(String accessToken);

    /**
     * 通过accessToken获取token
     *
     * @param accessToken
     * @return
     */
    public abstract Token getTokenByAccessToken(String accessToken);

    /**
     * 通过refreshToken获取token
     *
     * @param refreshToken
     * @return
     */
    public abstract Token getTokenByRefreshToken(String refreshToken);

    /**
     * 通过userId获取token
     *
     * @param userId
     * @return
     */
    public abstract Token getTokenByUserId(String userId);

    /**
     * 判断access_token是否过期
     *
     * @param token
     * @return
     */
    public abstract boolean isAccessTokenNonExpired(Token token);
}
